import junit.framework.TestCase;


public class BinarySearchTreeTest extends TestCase 
{

	private BinarySearchTree bst;
	
	protected void setUp() throws Exception {
		super.setUp();
		bst = new BinarySearchTree();
		bst.addItem(15, 1);
		bst.addItem(16, 2);
		bst.addItem(9, 3);
		bst.addItem(100, 4);
		bst.addItem(7, 5);
		bst.addItem(56, 6);
		bst.addItem(5, 7);
	}

	public void testAdd()
	{
		assertEquals("(1 (2 (3 (4 (5 (6 7))))))", bst.toString());
	}
	
	public void testGetItems()
	{
		bst.addItem("", 0);
		assertEquals("   15  16  9  100  7  56  5", bst.getItems());
	}

	public void testGetKeys()
	{
		assertEquals("null 1 null 2 null 3 null 4 null 5 null 6 null 7", bst.getKeys());
	}
	
	public void testSize()
	{
		assertEquals(7, bst.getSize());
	}

	public void testContainsKey()
	{
		assertEquals(false, bst.containsKey(0));
		assertEquals(true, bst.containsKey(1));
		assertEquals(true, bst.containsKey(6));
	}

	public void testContainsValue()
	{
		assertEquals(false, bst.containsValue(101));
		assertEquals(true, bst.containsValue(100));
		assertEquals(true, bst.containsValue(15));
	}
	
	public void testGetValue()
	{
		assertEquals("Niet gevonden", bst.getValue(0));
		assertEquals("15", bst.getValue(1));
		assertEquals("5", bst.getValue(7));
	}

	public void testGetHeight()
	{
		assertEquals(7, bst.getHeight());
	}

	public void testRemove()
	{
		bst.remove(7);
		assertEquals("(1 (2 (3 (4 (5 6)))))", bst.toString());
		bst.remove(1);
		assertEquals("(1 (2 (3 (4 (5 6)))))", bst.toString());
	}
	
}
